import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../routes/web_page_transitions.dart';
import 'colors.dart';
import 'text_styles.dart';

class AppTheme {
  static const String Font_Montserrat = 'Montserrat';

  static const String Font_YuYang = 'YuYang';

  /// 亮色主题样式
  static ThemeData light = ThemeData(
    useMaterial3: false,
    fontFamily: Font_Montserrat,
    primaryColor: Colours.app_main,
    colorScheme: ColorScheme.fromSwatch().copyWith(
      brightness: Brightness.light,
      secondary: Colours.app_main,
      error: Colours.red,
    ),
    appBarTheme: const AppBarTheme(
      elevation: 0.0,
      backgroundColor: Colors.white,
      foregroundColor: Color.fromARGB(200, 0, 0, 0),
      centerTitle: true,
      systemOverlayStyle: overDark,
      titleTextStyle: TextStyle(
        fontSize: 18,
        fontWeight: FontWeight.bold,
        color: Color.fromARGB(200, 0, 0, 0),
      ),
    ),
    // Tab指示器颜色
    indicatorColor: Colours.app_main,
    // 页面背景色
    scaffoldBackgroundColor: Colors.white,
    // 主要用于Material背景色
    canvasColor: Colors.white,
    // 文字选择色（输入框选择文字等）
    // textSelectionColor: Colours.app_main.withAlpha(70),
    // textSelectionHandleColor: Colours.app_main,
    // 稳定版：1.23 变更(https://flutter.dev/docs/release/breaking-changes/text-selection-theme)
    textSelectionTheme: TextSelectionThemeData(
      selectionColor: Colours.app_main.withAlpha(70),
      selectionHandleColor: Colours.app_main,
      cursorColor: Colours.app_main,
    ),
    textTheme: const TextTheme(
      // TextField输入文字颜色
      titleMedium: TextStyles.text,
      // Text文字样式
      bodyMedium: TextStyles.text,
      titleSmall: TextStyles.textGray12,
    ),
    inputDecorationTheme: InputDecorationTheme(
      hintStyle: TextStyles.textDarkGray14,
    ),
    dividerTheme:
        const DividerThemeData(color: Colours.line, space: 0.6, thickness: 0.6),
    cupertinoOverrideTheme: CupertinoThemeData(
      brightness: Brightness.light,
    ),
    pageTransitionsTheme: NoTransitionsOnWeb(),
    visualDensity: VisualDensity
        .standard, // https://github.com/flutter/flutter/issues/77142
  );

  /// 暗色主题样式
  static ThemeData dark = ThemeData(
    useMaterial3: false,
    fontFamily: Font_Montserrat,
    primaryColor: Colours.dark_app_main,
      colorScheme: ColorScheme.fromSwatch().copyWith(
        brightness: Brightness.dark,
        secondary: Colours.dark_app_main,
        error: Colours.dark_red,
      ),
    appBarTheme: const AppBarTheme(
        elevation: 0.0,
      backgroundColor: Color.fromARGB(255, 34, 34, 34),
      centerTitle: true,
      systemOverlayStyle: overLight,
      titleTextStyle: TextStyle(
        fontSize: 18,
        fontWeight: FontWeight.bold,
      ),
    ),
    bottomAppBarTheme: const BottomAppBarTheme(
      color: Color.fromARGB(255, 34, 34, 34),
    ),
      // Tab指示器颜色
      indicatorColor: Colours.dark_app_main,
      // 页面背景色
      scaffoldBackgroundColor: Colours.dark_bg_color,
      // 主要用于Material背景色
      canvasColor: Colours.dark_material_bg,
      // 文字选择色（输入框选择文字等）
      // textSelectionColor: Colours.app_main.withAlpha(70),
      // textSelectionHandleColor: Colours.app_main,
      // 稳定版：1.23 变更(https://flutter.dev/docs/release/breaking-changes/text-selection-theme)
      textSelectionTheme: TextSelectionThemeData(
        selectionColor: Colours.app_main.withAlpha(70),
        selectionHandleColor: Colours.app_main,
        cursorColor: Colours.app_main,
      ),
      textTheme: const TextTheme(
        // TextField输入文字颜色
        titleMedium: TextStyles.textDark,
        // Text文字样式
        bodyMedium: TextStyles.textDark,
        titleSmall: TextStyles.textDarkGray12,
      ),
      inputDecorationTheme: const InputDecorationTheme(
        hintStyle: TextStyles.textHint14,
      ),
      dividerTheme: const DividerThemeData(
        color: Colours.dark_line,
        space: 0.6,
        thickness: 0.6
      ),
      cupertinoOverrideTheme: CupertinoThemeData(
        brightness: Brightness.dark,
      ),
      pageTransitionsTheme: NoTransitionsOnWeb(),
      visualDensity: VisualDensity.standard,  // https://github.com/flutter/flutter/issues/77142
  );

  static const SystemUiOverlayStyle overLight = SystemUiOverlayStyle(
    statusBarColor: Colors.transparent,
    systemNavigationBarColor: Colours.dark_bg_color,
    systemNavigationBarIconBrightness: Brightness.light,
    statusBarIconBrightness: Brightness.light,
    statusBarBrightness: Brightness.dark,
  );

  static const SystemUiOverlayStyle overDark = SystemUiOverlayStyle(
    statusBarColor: Colors.transparent,
    systemNavigationBarColor: Colors.white,
    systemNavigationBarIconBrightness: Brightness.dark,
    statusBarIconBrightness: Brightness.dark,
    statusBarBrightness: Brightness.light,
  );
}
